package com.infotel.chat;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.StringReader;

public class ClientTimer implements ActionListener {

  
     BufferedReader br;
     BufferedWriter bw;
    
    public ClientTimer(){

        this.br=Client.getBr();
        this.bw=Client.getBw();
    }
    
    @Override
    public void actionPerformed(ActionEvent arg0) {
        try {
            if(!Client.fin){
            bw.write("LISTE MESSAGES\n");
            bw.flush();
            String line = "";
            StringBuilder sb = new StringBuilder();
            do {
                line = br.readLine();
                sb.append(line);
            } while (!line.equals("</chat>")
                    && !line.equals("<chat/>"));
            Client.zoneAffichage.setText(Chat
                    .getTexteMessages(new StringReader(sb
                            .toString())));
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
    }

}
